<?php

class Manager_CatalogController extends Zend_Controller_Action
{
    protected $form = null;
    protected $dbCatalog = null;
    public function init()
    {
         $this->form = new Manager_Form_Catalog();
         $this->dbCatalog = new Manager_Model_Catalog();
         $this->dbCategory = new Manager_Model_Category();
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        $this->view->data = $this->dbCatalog->getData();
    }
    public function formAction(){
        $this->view->cat = $this->dbCategory->getData();
        $this->view->form = $this->form;
        // action body
         $request = $this->getRequest();
       if($request->isPost()){
           $dataForm = $request->getPost();
           if($this->form->isValid($dataForm)){
                   $categoryName=$this->form->getValue('Category_Code');
                   $ProductName =$this->form->getValue('Product_Name');
                   $ProductInfo=$this->form->getValue('Product_Info');
                  $ProductImages=$this->form->getValue('Product_Images');
                   $PurchaseCost =$this->form->getValue('Purchase_Cost');
                   
                   $data = array('category_code'=>$categoryName,'product_name'=>$ProductName,
                       'product_info'=>$ProductInfo,'image'=>$ProductImages,'purchase_cost'=>$PurchaseCost);
                   $this->dbCatalog->catalogInserted($data);
                   
           }
       }
    }


}

